<template>
  <div class="app-container">
    <a-title></a-title>
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="任务名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入任务名称"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否里程碑" prop="milestoneFlag" label-width="100px">
        <el-select
          v-model="queryParams.milestoneFlag"
          placeholder="全部"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option label="是" value="1"></el-option>
          <el-option label="否" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="任务状态" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="全部"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option label="已完成" value="1"></el-option>
          <el-option label="未完成" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="执行人" prop="nickName">
        <el-input
          v-model="queryParams.nickName"
          placeholder="请输入执行人"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="参与人" prop="joinByName">
        <el-input
          v-model="queryParams.joinByName"
          placeholder="请输入参与人"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计划开始时间" label-width="100px">
        <el-date-picker
          v-model="queryParams.planStartTime"
          type="daterange"
          range-separator="-"
          value-format="yyyy-MM-dd"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="实际开始时间" label-width="100px">
        <el-date-picker
          v-model="queryParams.actualStartTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="计划结束时间" label-width="100px">
        <el-date-picker
          v-model="queryParams.planEndTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="实际结束时间" label-width="100px">
        <el-date-picker
          v-model="queryParams.actualEndTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="tableData"
      style="width: 100%;"
      row-key="id"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    >
      <el-table-column prop="name" label="业务名称"></el-table-column>
      <el-table-column prop="name" label="任务名称"></el-table-column>
      <el-table-column label="是否里程牌" width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.milestoneFlag=='1'">是</span>
          <span v-else>否</span>
        </template>
      </el-table-column>
      <el-table-column prop="status" label="任务状态" width="100">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === '1'" type="success" disable-transitions>已完成</el-tag>
          <el-tag v-else type="info" disable-transitions>未完成</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="计划开始时间" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planStartTime,'{y}-{m}-{d} ') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际开始时间" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualStartTime,'{y}-{m}-{d} ') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划结束时间" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planEndTime,'{y}-{m}-{d} ') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际结束时间" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualEndTime,'{y}-{m}-{d} ') }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="nickName" label="执行人" width="100"></el-table-column>
      <el-table-column prop="joinByName" label="参与人" width="120"></el-table-column>
      <el-table-column prop="remark" label="备注" :show-overflow-tooltip="true"></el-table-column>
    </el-table>
  </div>
</template>
<script>
import { formatDate } from '@/utils'
import aTitle from '@/components/Title'
export default {
  name: 'taskQuery',
  components: { aTitle },
  data () {
    return {
      // loading: true,
      queryParams: {
        name: undefined,
        milestoneFlag: undefined,
        status: undefined,
        nickName: undefined,
        joinByName: undefined,
        planStartTime: undefined,
        actualStartTime: undefined,
        planEndTime: undefined,
        actualEndTime: undefined
      },
      tableData: [],

    }
  },
  created () {
    this.getList();
  },
  mounted(){
    document.title=document.getElementById("projectNameTitle").innerHTML;
  },
  methods: {
    getList () {
      // this.loading = true;
      let params = {
        name: this.queryParams.name,
        milestoneFlag: this.queryParams.milestoneFlag,
        status: this.queryParams.status,
        nickName: this.queryParams.nickName,
        joinByName: this.queryParams.joinByName
      };

      //actualStartDateStart
      if (this.queryParams.planStartTime) {
        params.planStartDateStart = this.queryParams.planStartTime[0];
        params.planStartDateEnd = this.queryParams.planStartTime[1];
        //params.planStartTime = undefined;
      }
      if (this.queryParams.actualStartTime) {
        params.actualStartDateStart = this.queryParams.actualStartTime[0];
        params.actualStartDateEnd = this.queryParams.actualStartTime[1];
        //params.actualStartTime = undefined;
      }
      if (this.queryParams.planEndTime) {
        params.planStartDateStart = this.queryParams.planStartTime[0];
        params.planStartDateEnd = this.queryParams.planStartTime[1];
        //params.planEndTime = undefined;
      }
      if (this.queryParams.actualEndTime) {
        params.actualEndDateStart = this.queryParams.actualEndTime[0];
        params.actualEndDateEnd = this.queryParams.actualEndTime[1];
        //params.actualEndTime = undefined;
      }
      // listTask(params).then(response => {
      //   if (response.code === 200) {
      //     this.tableData = this.handleTreeString(response.data, "guid");
      //     console.log(this.tableData)
      //     this.loading = false;
      //   }
      //   //this.getTreeselect();
      // });
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.getList();
    },
    /*重置按钮操作 */
    resetQuery () {
      this.queryParams = {
        name: undefined,
        milestoneFlag: undefined,
        status: undefined,
        nickName: undefined,
        joinByName: undefined,
        planStartTime: undefined,
        actualStartTime: undefined,
        planEndTime: undefined,
        actualEndTime: undefined
      },
        this.handleQuery();
    },
  }
}
</script>
<style lang="scss" scoped>
.tabletitle {
  margin: 0 20px;
  .input-wrap {
    padding: 8px;
    display: flex;

    .input-label {
      min-width: 1em;
      max-width: 6em;
      color: rgba(0, 0, 0, 0.65);
      margin-right: 8px;
      display: flex;
      flex: 0 0 90px;
      margin-top: 5px;
    }

    .input-content {
      -webkit-box-flex: 1;
      flex-grow: 1;
      .el-select {
        width: 100%;
      }
    }
  }
}
.tablebox {
  height: 100%;
}
/deep/.el-table .cell {
  font-family: PingFangSC-Regular;
  color: rgba(0, 0, 0, 0.85);
  letter-spacing: 0;
  text-align: center;
  a {
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: #1890ff;
    letter-spacing: 0;
    text-align: right;
    line-height: 14px;
    margin: 0 10px;
  }
  .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 100%;
  }
}

.el-pagination {
  float: right;
  margin-top: 10px;
}
</style>